import Win from '../win.coffee'
import {app}  from "electron"
import platform from '@/config/platform.mjs'
import TITLE from '@/config/title.js'

{main} = Win

export default  (force_show=true)=>
  li = BrowserWindow.getAllWindows()
  # On macOS it's common to re-create a window in the app when the dock icon is clicked and there are no other windows open.
  if li.length
    for i from li
      if i.webContents.getURL().endsWith '/#main'
        win = i
        if win.isMinimized()
          win.restore()
        break
  if not win
    win = main(
      {
        type:''
        resizable: false
        height : 590
        width : 426
        skipTaskbar:false
      }
    )
    if platform == 'win32'
      win.setAppDetails(
        appId:TITLE
        appIconPath:process.execPath
      )
    ###
    win.on 'close',=>
      console.log 'main close'
      return
    ###
  if not force_show
    if not win.isVisible()
      return
  win.show()
  win.moveTop()
  win.focus()
  #v8gc()
  #setTimeout(
  #  show
  #  1000
  #)
  return
